package net.chenyan.server.specs;/**
 * @author chenyan
 * @createTime 2022/4/26 16:46
 * @description description
 */

/**
 *@description: TODO
 *@author: chenyan
 *@create: 2022/4/26 16:46
 */

import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.support.SimpleJpaRepository;

import javax.persistence.EntityManager;
import java.io.Serializable;

import static net.chenyan.server.specs.CustomerSpecs.*;

public class CustomRepositoryImpl <T, ID extends Serializable>
        extends SimpleJpaRepository<T, ID> implements
        CustomRepository<T,ID> {

    private  final EntityManager entityManager;

    public CustomRepositoryImpl(Class<T> domainClass, EntityManager entityManager) {
        super(domainClass, entityManager);
        this.entityManager = entityManager;
    }

    @Override
    public Page<T> findByAuto(T example, Pageable pageable) {
        return findAll(byAuto(entityManager, example),pageable);
    }
}
